package com.fhz.a1911.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;

import com.fhz.a1911.MyViewModel;
import com.fhz.a1911.R;


public class LeftFragment extends Fragment {
    private EditText leftFgEdit;
    private Button leftSend;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View inflate = inflater.inflate(R.layout.fragment_left, container, false);

        leftFgEdit = (EditText) inflate.findViewById(R.id.left_fg_edit);
        leftSend = (Button) inflate.findViewById(R.id.left_send);

        MyViewModel myViewModel = new ViewModelProvider(getActivity()).get(MyViewModel.class);

        leftSend.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String s = leftFgEdit.getText().toString();
                myViewModel.setString(s);
            }
        });

        return inflate;
    }
}